package com.ruoyi.wbs.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wbs.domain.ContractorPaymentRecord;
import com.ruoyi.wbs.service.IContractorPaymentRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 打款记录Controller
 * 
 * @author zhaogang
 * @date 2024-07-28
 */
@RestController
@RequestMapping("/wbs/paymentRecord")
public class ContractorPaymentRecordController extends BaseController
{
    @Autowired
    private IContractorPaymentRecordService contractorPaymentRecordService;

    /**
     * 查询打款记录列表
     */
    @PreAuthorize("@ss.hasPermi('wbs:paymentRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(ContractorPaymentRecord contractorPaymentRecord)
    {
        startPage();
        List<ContractorPaymentRecord> list = contractorPaymentRecordService.selectContractorPaymentRecordList(contractorPaymentRecord);
        return getDataTable(list);
    }

    /**
     * 导出打款记录列表
     */
    @PreAuthorize("@ss.hasPermi('wbs:paymentRecord:export')")
    @Log(title = "打款记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ContractorPaymentRecord contractorPaymentRecord)
    {
        List<ContractorPaymentRecord> list = contractorPaymentRecordService.selectContractorPaymentRecordList(contractorPaymentRecord);
        ExcelUtil<ContractorPaymentRecord> util = new ExcelUtil<ContractorPaymentRecord>(ContractorPaymentRecord.class);
        util.exportExcel(response, list, "打款记录数据");
    }

    /**
     * 获取打款记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('wbs:paymentRecord:query')")
    @GetMapping(value = "/{paymentId}")
    public AjaxResult getInfo(@PathVariable("paymentId") Long paymentId)
    {
        return success(contractorPaymentRecordService.selectContractorPaymentRecordByPaymentId(paymentId));
    }

    /**
     * 新增打款记录
     */
    @PreAuthorize("@ss.hasPermi('wbs:paymentRecord:add')")
    @Log(title = "打款记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ContractorPaymentRecord contractorPaymentRecord)
    {
        return toAjax(contractorPaymentRecordService.insertContractorPaymentRecord(contractorPaymentRecord));
    }

    /**
     * 修改打款记录
     */
    @PreAuthorize("@ss.hasPermi('wbs:paymentRecord:edit')")
    @Log(title = "打款记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ContractorPaymentRecord contractorPaymentRecord)
    {
        return toAjax(contractorPaymentRecordService.updateContractorPaymentRecord(contractorPaymentRecord));
    }

    /**
     * 删除打款记录
     */
    @PreAuthorize("@ss.hasPermi('wbs:paymentRecord:remove')")
    @Log(title = "打款记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{paymentIds}")
    public AjaxResult remove(@PathVariable Long[] paymentIds)
    {
        return toAjax(contractorPaymentRecordService.deleteContractorPaymentRecordByPaymentIds(paymentIds));
    }
}
